<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>账户管理-列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/xadmin.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/admin.css">
    <script src="${pageContext.request.contextPath}/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/xadmin.js"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">账户管理</a>
            <a>
              <cite>用户信息</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <!-- <div class="layui-col-md3"></div> -->
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body " style="padding-top: 16px;">
                    <form class="layui-form layui-col-space5" action="/findByConditions" method="post" style="float:left;">

                        <div class="layui-input-inline layui-show-xs-block">
                            <input class="layui-input" placeholder="id" name="user_id" ></div>
                        <div class="layui-input-inline layui-show-xs-block">
                            <input class="layui-input" placeholder="姓名" name="username" ></div>
                        <div class="layui-input-inline layui-show-xs-block">
                            <select name="role_type" lay-verify="">
                                <option value="">请选择角色</option>
                                <option value="0">管理员</option>
                                <option value="1">业务员</option>
                                <option value="2">审核员</option>
                                <option value="3">公告发布员</option>
                            </select>
                        </div>


                        <div class="layui-input-inline layui-show-xs-block">
                            <button class="layui-btn" lay-submit="" lay-filter="sreach">
                                <i class="layui-icon">&#xe615;</i>搜索</button>
                        </div>
                    </form>
                    <button title="添加用户" class=" layui-btn"  onclick="location.href='/adminAdd'" style="margin-top: 0;float: right">
                        <i class="layui-icon"></i>添加账户
                    </button>


                </div>


                <div class="layui-card-body layui-table-body layui-table-main" style="clear: both">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>

                            <th>id</th>
                            <th>用户名</th>
                            <th>电子邮箱</th>
                            <th>电厂</th>
                            <th>角色</th>
                            <th>操作</th></tr>
                        </thead>
                        <tbody>
                        <c:forEach items="${pageinfo.list}" var="user">
                            <tr>

                                <td>${user.user_id}</td>
                                <td>${user.username}</td>
                                <td>${user.email}</td>
                                <td>
                                    <c:if test="${user.dept.deptId == 1}">中能热电</c:if>
                                    <c:if test="${user.dept.deptId == 2}">核能热电</c:if>
                                    <c:if test="${user.dept.deptId == 3}">超能热电</c:if>
                                    <c:if test="${user.dept.deptId == 4}">风能热电</c:if>
                                </td>
                                <td>${user.role.role_name}</td>

                                <td class="td-manage">
                                    <c:choose>
                                        <c:when test="${user.role.role_type==0}">
                                            <a title="查看"  onclick="xadmin.open('查看','${pageContext.request.contextPath}/show?id=${user.user_id}',500,550)" href="javascript:;">
                                                <i class="layui-icon">&#xe67b;</i>查看&thinsp; &thinsp; &thinsp;
                                            </a>

                                        </c:when>
                                        <c:otherwise>
                                            <a onclick="location.href='${pageContext.request.contextPath}/editpassword?id=${user.user_id}'" title="修改密码" href="javascript:;">
                                                <i class="layui-icon">&#xe631;</i>修改密码&thinsp; &thinsp; &thinsp;
                                            </a>
                                            <a title="编辑"  onclick="location.href='${pageContext.request.contextPath}/preEdit?id=${user.user_id}'" href="javascript:;">
                                                <i class="layui-icon">&#xe642;</i>编辑&thinsp; &thinsp; &thinsp;
                                            </a>

                                            <a title="删除" onclick="location.href='${pageContext.request.contextPath}/deleteUser?id=${user.user_id}'" href="javascript:;">
                                                <i class="layui-icon">&#xe640;</i>删除
                                            </a>
                                        </c:otherwise>
                                    </c:choose>

                                </td>
                            </tr>
                        </c:forEach>

                        </tbody>
                    </table>
                </div>
                <div >


                <div class="page">
                    <div>
                        <a class="prev" href="${pageContext.request.contextPath}/findAll?page=1&size=${pageinfo.pageSize}">首页</a>
                        <a class="num" href="${pageContext.request.contextPath}/findAll?page=${pageinfo.pageNum-1}&size=${pageinfo.pageSize}">上一页</a>

                            <c:forEach begin="1" end="${pageinfo.pages}" var="pageNum">

                                <a href="${pageContext.request.contextPath}/findAll?page=${pageNum}&size=${pageinfo.pageSize}"
                                        <c:if test="${pageNum eq pageinfo.pageNum}" > style="
                                            display: inline-block;
                                            background: #409ccf;
                                            color: #fff;
                                            padding: 5px;
                                            min-width: 15px;
                                            border: 1px solid #409ccf;
                                            " </c:if> >
                                        ${pageNum}</a>

                            </c:forEach>

                            <a class="num" href="${pageContext.request.contextPath}/findAll?page=${pageinfo.pageNum+1}&size=${pageinfo.pageSize}">下一页</a>
                            <a class="next" href="${pageContext.request.contextPath}/findAll?page=${pageinfo.pages}&size=${pageinfo.pageSize}">尾页</a>
                        </div>
                    </div>
                    <div style="text-align:  center;padding: 16px 0 36px 0;font-size: 13px;color: #818181;">

                            总共${pageinfo.pages} 页，共${pageinfo.total} 条数据 <%--每页
                        <select  id="changePageSize" onchange="changePageSize()">
                            <option <c:if test="${pageinfo.size==1}">selected</c:if> >1</option>
                            <option <c:if test="${pageinfo.size==2}">selected</c:if> >2</option>
                            <option <c:if test="${pageinfo.size==3}">selected</c:if> >3</option>
                            <option <c:if test="${pageinfo.size==4}">selected</c:if> >4</option>
                            <option <c:if test="${pageinfo.size==5}">selected</c:if> >5</option>
                        </select> 条--%>

                    </div>


                </div>
            </div>
            <!-- .box-footer-->


            <!-- /.box-footer-->

        </div>
        <!-- <div class="layui-col-md3"></div> -->

    </div>
</div>
</body>
<script>

    function changePageSize() {
        //获取下拉框的值
        var pageSize = $("#changePageSize").val();

        //向服务器发送请求，改变没页显示条数
        location.href = "${pageContext.request.contextPath}/findAll?page=1&size="
            + pageSize;
    }


    layui.use(['laydate', 'form'],
        function() {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#start' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#end' //指定元素
            });
        });

    /*用户-删除*/
    function member_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            $(obj).parents("tr").remove();
            layer.msg('已删除!',{icon:1,time:1000});
        });
    }

</script>
</html>